<?php

if ( function_exists('register_sidebars') )
	register_sidebars(2);

if(!get_option('part_per_post')){

add_filter('the_content', 'concise_the_content');
function concise_the_content($content) {
        global $index_page;
        if($index_page){
                $content = preg_replace('/<img([^>]*)>/i'," ", $content); #PEAK ADD|To deal with sina blog
//                $content = preg_replace('/<a([^>]*)>/i'," ", $content); #PEAK ADD|To deal with sina blog
                $content = preg_replace('/<span([^>]*)>/i',"<span> ", $content); #PEAK ADD|To deal with sina blog
                $content = preg_replace('/<([^>p]*)>/i'," ", $content); #PEAK ADD|To deal with sina blog
                $content = preg_replace('/<p([^>]*)>/i',"<p>", $content); #PEAK ADD|To deal with sina blog

                mb_internal_encoding("UTF-8");
                $len = mb_strlen($content);
                $content = mb_substr($content, 0,252);
                $content = preg_replace('/<([^>]*)$/i'," ", $content); #PEAK ADD|To deal with sina blog
                $num1=0;$num2=0;
                preg_match_all("/(<div)/",$content,$matched1,PREG_PATTERN_ORDER);
                preg_match_all("/(<\/div)/",$content,$matched2,PREG_PATTERN_ORDER);
                $num1=count($matched1[1]);
                $num2=count($matched2[1]);

                $num1=0;$num2=0;
                preg_match_all("/(<b)/",$content,$matched1,PREG_PATTERN_ORDER);
                preg_match_all("/(<\/b)/",$content,$matched2,PREG_PATTERN_ORDER);
                $num1=count($matched1[1]);
                $num2=count($matched2[1]);
                for($i=0;$i<$num1-$num2;$i++) $content.="</b>\n";

                $num1=0;$num2=0;
                preg_match_all("/(<font)/",$content,$matched1,PREG_PATTERN_ORDER);
                preg_match_all("/(<\/font)/",$content,$matched2,PREG_PATTERN_ORDER);
                $num1=count($matched1[1]);
                $num2=count($matched2[1]);
                for($i=0;$i<$num1-$num2;$i++) $content.="</font>\n";



		if($len>200){
                $content.=" ...\n";
		}
                for($i=0;$i<$num1-$num2;$i++) $content.="</div>\n";
                return $content;
        }
        return str_replace('<p>&nbsp;</p>', '', $content);
}
}

?>
